import { createElement } from 'react';
import { classPrefix, linkProp } from '../../variables';
import useInsertClass from '../../hooks/useInsertClass';
import './index.scss';

export interface ButtonProp extends linkProp{
  /**
   * 按E钮
   */
  text?: React.ReactNode;
  /**
   * 点击事件
   */
  onClick?: (event: any) => any;
}

function Button(props: ButtonProp) {
  const {
    uiConfig = {},
    style = {},
    className = '',
    text,
    onClick = () => {},
    url,
  } = props;
  const insertClass = useInsertClass(uiConfig, {
    pick: ['size', 'color', 'border-radius'],
    default: { 'border-radius': 'm' }
  });
  const compClass = [insertClass, `${classPrefix}-button`, className].filter(t => t).join(' ');
  return (
    <div data-url={url} className={compClass} style={style} onClick={onClick}>按钮：{text}</div>
  );
};

Button.displayName = 'Button';
export default Button;
